package com.llb666.e.shop.domain.service;

import com.llb666.e.shop.api.vo.CategoryVo;
import com.llb666.e.shop.api.vo.NewItemsVo;
import com.llb666.e.shop.domain.entity.Category;
import com.llb666.e.shop.domain.repository.CategoryRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商品类目.
 *
 * @author 斌~
 * @date 2022/8/29 下午9:36
 */
@Service
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class CategoryService {

    private final CategoryRepository categoryRepository;

    /**
     * 查询一级商品类目.
     *
     * @return 一级商品类目列表
     */
    public List<Category> queryAllCategoryRoot() {
        return categoryRepository.queryAllCategoryRoot();
    }

    /**
     * 首页滚动加载商品推荐.
     *
     * @param rootCatId 父级商品分类Id
     * @return 商品列表
     */
    public List<NewItemsVo> getSixNewItemsLazy(Integer rootCatId) {
        return categoryRepository.getSixNewItemsLazy(rootCatId);
    }

    /**
     * 查询子分类商品类目.
     *
     * @param rootCatId 父级分类Id
     * @return 子分类商品类目列表
     */
    public List<CategoryVo> getSubCatList(Integer rootCatId) {
        return categoryRepository.getSubCatList(rootCatId);
    }
}
